{include file="public/header" /}
{load href="__PLUGINS__iCheck/icheck.min.js"}
{load href="__PLUGINS__iCheck/custom.css"}
    {load href="__CSS__video-js.min.css"}
    {load href="__JS__video.min.js"}
<!-- 加载编辑器的容器 -->
{:ueditor()}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <form class="form-horizontal" method="post">
            <div class="col-sm-12">
                <div class="tabs-container">

                                <div class="form-group">
                                    <label class="col-sm-2 control-label">发布方式：</label>
                                    <div class="col-sm-9">
                                        <div class="radio i-checks">
                                            <label>
                                                <input type="radio" value="0" name="addway" {present name='name'}{eq name="name.addway" value="0"}checked{/eq}{else/}checked{/present}>后台发布
                                            </label>
                                            <label>
                                                <input type="radio" value="2" name="addway" {present name='name'}{eq name="name.addway" value="2"}checked{/eq}{/present}>用户自主发布
                                            </label>
                                        </div>
                                    </div>
                                </div>
                    <div class="form-group" id="userid" {present name="name"}{if condition="$name.type == 3"}style="display: none"{/if}{/present}>
                    <label class="col-sm-2 control-label">用户：</label>
                    <div class="col-sm-9">
                        <input name="userid" type="number" class="form-control" value="{present name='name'}{$name.userid}{else /}<?php if (input('userid')) {echo input('userid');}?>{/present}">
                    </div>
                </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">点赞数：</label>
                <div class="col-sm-9">
                    <input name="thumbsup" type="number" class="form-control" value="{present name='name'}{$name.thumbsup}{/present}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">虚拟点赞数：</label>
                <div class="col-sm-9">
                    <input name="xuni_thumbsup" type="number" class="form-control" value="{present name='name'}{$name.xuni_thumbsup}{/present}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">评论数：</label>
                <div class="col-sm-9">
                    <input name="comments" type="number" class="form-control" value="{present name='name'}{$name.comments}{/present}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">浏览量：</label>
                <div class="col-sm-9">
                    <input name="visit" type="number" class="form-control" value="{present name='name'}{$name.visit}{/present}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">内容：</label>
                <div class="col-sm-9">
                    <textarea name="content" id="content" style="height: 400px;width: 100%">{present name="name"}{$name.content}{/present}</textarea>
                </div>
            </div>



            <div class="form-group">
                <label class="col-sm-2 control-label">图片：</label>
                <div class="col-sm-9">
                    <div id="demo"></div>
                </div>
            </div>

            <input name="masterimg" id="images" type="hidden" class="form-control" value="">

            <style type="text/css">
                .meiyouuimmag{
                    margin-bottom: 20px;
                    height:284px;
                    overflow: hidden;
                }
                .meiyouuimmag div{
                    width: 100%;
                    margin-bottom: 10px;
                    overflow:hidden;
                    height: 200px
                }
                .meiyouuimmag div img{
                    width: 100%
                }
                .meiyouuimmag button{
                    position: absolute;
                    right: 15px;
                    display: block;
                }
                #imagasdasd{
                    margin-left: 100px;
                    margin-right: 100px;
                }
            </style>

            <div class="form-group" id="imagasdasd">
                {present name="$name"}
                {if condition="$name.masterimg"}
                {php}$imagesdata = json_decode($name['masterimg'],TRUE);$k=0;{/php}
                {foreach $imagesdata as $v}
                <div class="col-md-3 col-sm-4 col-xs-6 meiyouuimmag" id="id{$k}">
                    <button type="button" class="btn btn btn-sm btn-danger" onclick="delImg({$k})">删除</button>
                    <div class="im"><img src="__ROOT__{$v}" >  </div>
                    <textarea data-img="{$v}" style="resize:none" class="form-control" rows="3"></textarea>
                </div>
                <?php $k++;?>
                {/foreach}
                {/if}
                {/present}
            </div>

            <!-- 引用控制层插件样式 -->
            {load href="__PLUGINS__zyUpload/zyUpload.css"}
            <!-- 引用核心层插件 -->
            {load href="__PLUGINS__zyUpload/zyUpload.js"}
            <!-- 引用初始化JS -->
            <script type="text/javascript">var urlupload='{:url('index/uploads')}'; var root = '__ROOT__'</script>
            {load href="__PLUGINS__zyUpload/script.js"}

            <div class="form-group" >
                <label class="col-sm-2 control-label">视频：</label>
                <div class="col-sm-9">
                    <div class="input-group">
                        <video class="video-js vjs-default-skin" src="{present name='name.video'}{if condition='$name.video'}{$name.show_video}{/if}{/present}" volume="0.5" poster="{present name='name.cover'}{if condition='$name.cover'}__ROOT__{$name.cover}{/if}{/present}" controls preload="true" id="video">您的浏览器不支持播放本视频</video>
                        <input name="video" type="hidden"  id="videoval" class="form-control" value="{present name='name'}{$name.video}{/present}">
                        <span class="input-group-btn" id="videowatch">
                                            <button type="button" class="btn btn-primary" id="videos">上传</button>
                                        </span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">封面：</label>
                <div class="col-sm-9">
                    <div class="input-group">
                        <img src="{present name='name.cover'}{if condition='$name.cover'}__ROOT__{$name.cover}{else /}__IMG__add_img.png{/if}{else /}__IMG__add_img.png{/present}" id="imageimg" style="max-width: 200px">
                        <input name="cover" type="hidden"  id="image" class="form-control" value="{present name='name'}{$name.cover}{/present}">
                        <span class="input-group-btn">
                                            <button type="button" class="btn btn-primary" id="tubiao">上传</button>
                                        </span>
                    </div>
                </div>
            </div>
    </div>
</div>
</div>
</div>
</form>
</div>
</div>
{include file="public/footer" /}
<script type="text/javascript">

    layui.use(['laydate'], function(){
        var laydate = layui.laydate;
        var form = layui.form;

        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
            ,trigger: 'click'
        });
    })


    $(document).ready(function(){
        $(".i-checks").iCheck({
            checkboxClass: "icheckbox_square-green",
            radioClass: "iradio_square-green",
        })
    });
    function msg(){
        layer.msg("上传成功")
    }
    function time(){
        laydate(
            {
                fixed: false,
                istime: true,
                format: 'YYYY-MM-DD hh:mm:ss',
                zIndex: 999999999999,
                isclear: false,
            }
        )
    }
    function delImg(id){
        $('#id'+id).remove();
    }
    $("#videos").click(function(){
        //  layer.msg('演示站无权操作！')
        // return;
        layer.open({
            type: 2,
            title: '上传视频',
            shadeClose: true,
            shade: 0.2,
            area: ['70%', '60%'],
            skin:'shangchuantup',
            content: '{:url("index/videoUploads")}',
            shift:-1,
            scrollbar: false,
            moveType: 1,
            moveOut: true
        });
    })

    function chan(obj){
        if ($(obj).val() == 1) {
            $('#category_id').show();
            $('#userid').show();
            $('#to_user').show();
            $('#datetime').show();
            $('#citys').show();
            $('#top').hide();
        } else if($(obj).val() == 2) {
            $('#category_id').hide();
            $('#userid').hide();
            $('#to_user').hide();
            $('#datetime').show();
            $('#citys').show();
            $('#top').show();
        } else {
            $('#category_id').hide();
            $('#userid').show();
            $('#to_user').hide();
            $('#datetime').hide();
            $('#citys').hide();
            $('#top').hide();
        }
    }
    function searchtopic(key = 1) {
        let keyword = $(`#searchtopic${key}`).val();
        ajaxFun("post","{:url('searchtopic')}",{keyword},'json',function(ret){
            if(ret){
                let html = ''
                ret.forEach(item=>{
                    html += `<option value="${item.name}">${item.name}</option>`
                })
                $(`#topicselect${key}`).html(html)
            }else{
                swal_msg("错误",ret,"error");
            }
        })
    }

    function addtopic(key = 1) {
        let select = $(`#topicselect${key}`).val()
        if (!select) return;
        let pause = false
        $(`input[name^="topic${key}"]`).each(function(){
            if (select == $(this).val()) return pause = true;
        }); 
        if (pause) return;
        let names = ['','_experience'];
        $(`#topics${key}`).append(`<label>
                            <input type="checkbox" name="topic${names[key - 1]}[]" checked value="${select}">${select}
                        </label>`)

        $(".i-checks").iCheck({
            checkboxClass: "icheckbox_square-green",
            radioClass: "iradio_square-green",
        })
    }


    setTimeout(() => {
        '{if condition="isset($name) && $name.video"}'
            videojs('video', {
                fluid: false,
                autoplay: false,
                width: 300,
                sources: [{
                    src: "{:strpos($name.video, 'http')===false?'__ROOT__':''}{$name.video}",
                    <?php 
                    if (strpos($name['video'], 'm3u8') !== false) {
                        ?>
                    type: 'application/x-mpegURL'
                    <?php } ?>
                }]
            });
        '{/if}'
    }, 300);
</script>
{include file="public/bottom" /}

